<template>
  <div class="login">
    <p>欢迎登录 - MMALL管理系统</p>
    <p>
      <input type="text" placeholder="请输入账号" v-model="ruleForm.username" />
    </p>
    <p>
      <input type="text" placeholder="请输入密码" v-model="ruleForm.password" />
    </p>
    <p><button class="btn" @click="login">登录</button></p>
  </div>
</template>

<script>
import { login } from "@/utils/api";
export default {
  name: "",
  components: {},
  data() {
    return {
      ruleForm: {
        username: "",
        password: ""
      }
    };
  },
  mounted() {},
  methods: {
    login() {
      login(this.ruleForm).then(res => {
        console.log(res);
        if (res.data.status == 0) {
          this.$router.push("/home");
        } else {
          alert("用户名或密码错误");
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.login {
  width: 400px;
  height: 200px;
  background: #ccc;
  margin: 0 auto;
  text-align: center;
}
input {
  width: 300px;
  height: 20px;
  outline: none;
}
.btn {
  width: 400px;
  height: 40px;
  text-align: center;
  line-height: 20px;
  font-size: 20px;
  background: skyblue;
  border: none;
  border-radius: 10px;
  outline: none;
}
</style>
